package com.woniuxy.educationplatform.controller;

import com.woniuxy.educationplatform.bean.RoleBean;
import com.woniuxy.educationplatform.bean.StatusBean;
import com.woniuxy.educationplatform.service.IRoleService;
import com.woniuxy.educationplatform.service.IStatusService;
import com.woniuxy.educationplatform.util.ResultUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/status")
public class StatusController {
    @Resource
    private IStatusService statusService;

    /**
     * 查询所有状态正常的角色
     * @return 返回result工具类对象
     */
    @RequestMapping("/findAll")
    public ResultUtil findAllStatus(){
        List<StatusBean> statusBeans = statusService.findAllStatus();
        ResultUtil<List<StatusBean>> resultUtil = new ResultUtil<>();
        if (statusBeans == null) {
            resultUtil.setCode(ResultUtil.ERROR).setMessage("出错了…… 没有找到");
        }else {
            resultUtil.setCode(ResultUtil.SUCCESS).setMessage("请求成功").setData(statusBeans);
        }
        return resultUtil;
    }
}
